import { _decorator, AudioClip, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('SoundManager')
export class SoundManager extends Component {
    private static _instance: SoundManager = null;

    public static get instance(): SoundManager {
        return SoundManager._instance;
    }

    @property(AudioClip)
    coinAudio:AudioClip = null;

    @property(AudioClip)
    arrowHitAudio:AudioClip = null;

    @property(AudioClip)
    bombHitAudio:AudioClip = null;
    
    @property(AudioClip)
    bgm:AudioClip = null;

    @property(AudioClip)
    dead:AudioClip = null;

    protected onLoad(): void {
        SoundManager._instance = this;
    }

    start() {

    }

    playBgm(){
        this.bgm.setLoop(true);
        this.bgm.play();
    }

    stopBgm(){
        this.bgm.stop();
    }

    playCoinAudio(){
        this.coinAudio.play();
    }

    playArrowHitAudio(){
        this.arrowHitAudio.setVolume(0.7);
        this.arrowHitAudio.play();
    }

    playBombHitAudio(){
        this.bombHitAudio.setVolume(0.7);
        this.bombHitAudio.play();
    }

    playDeadAudio(){
        this.dead.setVolume(0.7);
        this.dead.play();
    }
    
}   


